package com.beok.android.joylife.fragment;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.Toast;

import com.beok.android.joylife.ListViewAdapter;
import com.beok.android.joylife.R;
import com.melnykov.fab.FloatingActionButton;
import com.melnykov.fab.ScrollDirectionListener;

/**
 * Created by Administrator on 2015/1/30.
 */
public class ListViewFragment extends Fragment {

    @SuppressLint("InflateParams")
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.fragment_listview, container, false);

        ListView list = (ListView) root.findViewById(android.R.id.list);
        ListViewAdapter listAdapter = new ListViewAdapter(getActivity(),
                getResources().getStringArray(R.array.countries));
        list.setAdapter(listAdapter);

        FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.fab);
//        FloatingActionButton fab2 = (FloatingActionButton) root.findViewById(R.id.fab2);
        fab.attachToListView(list, new ScrollDirectionListener() {
            @Override
            public void onScrollDown() {
                Log.d("ListViewFragment", "onScrollDown()");
            }

            @Override
            public void onScrollUp() {
                Log.d("ListViewFragment", "onScrollUp()");
            }
        });
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(v.getContext(), "fengchao", Toast.LENGTH_SHORT).show();
            }
        });

        return root;
    }
}